package com.admin.action;

import com.admin.service.StatisticsAdminService;
import com.client.bean.FeedBack;
import com.data.util.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * 统计管理，包括反馈信息，举报软件信息的等，以及其他
 *
 * @author:HingLo
 * @create 2017-10-13 15:16
 **/
@Controller
@RequestMapping("/statisticsAdmin/admin/")
public class StatisticsAdminAtion {

    @Autowired
    private StatisticsAdminService statisticsAdminService;

    /**
     * 查看反馈信息
     *
     * @param request
     * @return
     */
    @GetMapping("inputFeedback")
    public String inputFeedbackAction(HttpServletRequest request) {
        List<FeedBack> list = statisticsAdminService.findFeedbackService();
        request.setAttribute("dataMap", list);
        return "/WEB-INF/admin/info/feedback";
    }

    /**
     * 查看举报信息
     *
     * @param request
     * @return
     */
    @GetMapping("inputReport")
    public String inputReportAction(HttpServletRequest request) {
        List<?> list = statisticsAdminService.findReportService();
        request.setAttribute("dataMap", list);
        return "/WEB-INF/admin/info/report";
    }

    /**
     * 修改消息状态
     *
     * @param type 0:举报 1：表示反馈
     * @param id
     * @return
     */

    @PostMapping("signInfoState")
    @ResponseBody
    public Map<String, Object> signInfoStateAction(int type, String id) {
        boolean bool = statisticsAdminService.signInfoStateService(id, type);
        return bool ? JsonUtils.returnMassageUtils(true, "标记成功") : JsonUtils.returnMassageUtils(false, "标记失败");

    }

    /**
     * 删除消息
     *
     * @param type 0:举报 1：表示反馈
     * @param id
     * @return
     */

    @PostMapping("deleteInfoState")
    @ResponseBody
    public Map<String, Object> deleteInfoStateAction(int type, String id) {
        boolean bool = statisticsAdminService.delInfoStateService(id, type);
        return bool ? JsonUtils.returnMassageUtils(true, "删除成功") : JsonUtils.returnMassageUtils(false, "删除失败");

    }

}
